package pers.jl.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@MapperScan("pers/jl/mapper")// 推荐将扫描mapper包的注解卸载mybatisplus的配置类上
public class MybatisPlusConfig {

    // 配置一个分页插件
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        // 创建一个mybatisplus拦截器对象
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        // 添加分页插件，并设置分页数据库类型为Mysql
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }
}
